import {ref, Ref} from 'vue'
import {EngineInterface} from "@aomao/engine";

export default function (engine: Ref<EngineInterface | null>) {

    const titleInputRef = ref<HTMLTextAreaElement | null>(null);

    function handleTitleEnter() {
        if (engine.value) {
            engine.value.focus();
        }
    }

    function handleTitleInput() {
        if (titleInputRef.value) {
            titleInputRef.value.style.height = '';
            titleInputRef.value.style.height = titleInputRef.value.scrollHeight + 'px';
        }
    }

    return {
        handleTitleEnter,
        handleTitleInput,
        titleInputRef
    }

}
